package zuoye07;

import java.io.*;

public class zuoye05 {
         public static void main(String[] args) throws FileNotFoundException {
             File src = new File("E:\\培训\\oracleday4");
             llll(src);
         }
         public static void llll(File src) throws FileNotFoundException {
             File[] arr=src.listFiles();
             File desc=new File("ceshi");
             if(arr!=null) {
                 for (File f : arr) {
                     if (f.isDirectory()) {
                         File subDesc = new File(desc, f.getName());
                         subDesc.mkdirs();
                         llll(f);
                     }
                     else {
                         try {
                             File targetFile = new File(desc, f.getName());
                             FileInputStream fis = new FileInputStream(f);
                             FileOutputStream fos = new FileOutputStream(targetFile);
                             byte[] b = new byte[1024];
                             int len;
                             if((len=fis.read(b))>0)
                             {
                                 fos.write(b,0,len);

                             }
                             fis.close();
                             fos.close();
                         }
                         catch (FileNotFoundException e) {
                             System.out.println("kong");
                             throw new FileNotFoundException();

                         } catch (IOException e) {
                             throw new RuntimeException(e);
                         }

                     }
                 }
             }
         }
}
